#ifndef AQBUFF_H
#define AQBUFF_H

#include <vector>
#include <string>

namespace AQBUFFER
{
    class BUFFER
    {
    private:
        std::vector<char> buffer;
        unsigned int readIndex;
        unsigned int writeIndex;
        static const unsigned int initsize = 1024;
        static const unsigned int prependsize = 8;

    public:
        BUFFER();
        char *Begin();
        int size();
        void hTon(void *data, int len);
        void nToh(void *data, int len);
        unsigned int prependable();
        unsigned int readable();
        unsigned int writable();
        char *beginRead();
        char *beginWrite();
        void fix_readIndex(int len);
        void fix_writeIndex(int len);
        void makeSpace(int len);
        void write(const void *data, int len);
        void write(const char *data, int len);
        void prepend(int len);
        void writeint(int x);
        /* extendibility */
        void writestring(std::string &s);
        /* extendibility */
        int readint();
        /* extendibility */
        std::string readstring(int len);
        long readFd(int fd);
    };

}

#endif